Page({
  data: {
    countdown: 5, 
  },

  onLoad() {
    this.startCountdown();
  },

  startCountdown() {
    const timer = setInterval(() => {
      let currentCount = this.data.countdown;
      if (currentCount > 0) {
        currentCount--;
        this.setData({
          countdown: currentCount,
        });
      } else {
        clearInterval(timer);
        // 倒计时结束，跳转页面
        wx.switchTab({
          url: '/pages/my/my'
        });
      }
    }, 1000);
  },
});